<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/11/5
 * Time: 9:54
 */

namespace app\api\controller;



use app\api\service\LearnDataService;
use app\common\exception\CustomException;

class LearnDataController extends BaseController
{
    /**
     * @name 学习数据处理
     * @author wx
     * @date 2020/11/5 9:55
     */
    public function handle()
    {
        set_time_limit(0);

        //接收参数
        $data = file_get_contents('php://input', 'r');
        $this->addRuntimeLog('../runtime/learn_data_finish.log', $data);

        $data = json_decode($data,true);

        if(!isset($data['data']['learn_number'])){
            throw new CustomException('learn_number为必须参数', '202');
        }

        if(!isset($data['hostid'])){
            throw new CustomException('hostid为必须参数', '202');
        }

        //1. 接收参数
        $hostId = $data['hostid'];
        $learnNumber = $data['data']['learn_number'];

        $server = new LearnDataService();
        $data = $server->handle($hostId, $learnNumber);

        return $this->jsonOutPut($data);

    }


}